import 'package:aweb5/bean/aplus/fromlib_material_entity.dart';
import 'package:video_player/video_player.dart';

fromlibMaterialEntityFromJson(FromlibMaterialEntity data, Map<String, dynamic> json) {
	if (json['msg'] != null) {
		data.msg = json['msg']?.toString();
	}
	if (json['data'] != null) {
		data.data = new FromlibMaterialData().fromJson(json['data']);
	}
	if (json['code'] != null) {
		data.code = json['code']?.toInt();
	}
	return data;
}

Map<String, dynamic> fromlibMaterialEntityToJson(FromlibMaterialEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['msg'] = entity.msg;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['code'] = entity.code;
	return data;
}

fromlibMaterialDataFromJson(FromlibMaterialData data, Map<String, dynamic> json) {
	if (json['task_info'] != null) {
		data.taskInfo = new List<FromlibMaterialDataTaskInfo>();
		(json['task_info'] as List).forEach((v) {
			data.taskInfo.add(new FromlibMaterialDataTaskInfo().fromJson(v));
		});
	}
	if (json['follow_id'] != null) {
		data.followId = json['follow_id']?.toInt();
	}
	if (json['is_official'] != null) {
		data.isOfficial = json['is_official']?.toInt();
	}
	return data;
}

Map<String, dynamic> fromlibMaterialDataToJson(FromlibMaterialData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.taskInfo != null) {
		data['task_info'] =  entity.taskInfo.map((v) => v.toJson()).toList();
	}
	data['follow_id'] = entity.followId;
	data['is_official'] = entity.isOfficial;
	return data;
}

fromlibMaterialDataTaskInfoFromJson(FromlibMaterialDataTaskInfo data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	if (json['type'] != null) {
		data.type = json['type']?.toInt();
	}
	if (json['content'] != null) {
		data.content = json['content']?.toString();
	}
//	if (json['controller'] != null) {
//		data.controller = new VideoPlayerController().fromJson(json['controller']);
//	}
	if (json['index'] != null) {
		data.index = json['index']?.toInt();
	}
	if (json['linkTitle'] != null) {
		data.linkTitle = json['linkTitle']?.toString();
	}
	if (json['linkPrice'] != null) {
		data.linkPrice = json['linkPrice']?.toString();
	}
	return data;
}

Map<String, dynamic> fromlibMaterialDataTaskInfoToJson(FromlibMaterialDataTaskInfo entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['type'] = entity.type;
	data['content'] = entity.content;
//	if (entity.controller != null) {
//		data['controller'] = entity.controller.toJson();
//	}
	data['index'] = entity.index;
	data['linkTitle'] = entity.linkTitle;
	data['linkPrice'] = entity.linkPrice;
	return data;
}